// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import 'babel-polyfill'
import '@/assets/css/index.less'
import Vue from 'vue'
import App from './App'
import router from './router'
import store from '@/store/index.js'
import http from '@/util/http/index.js'
import fastClick from 'fastclick'
import VueI18n from 'vue-i18n'

// import objectAssign from 'object-assign'
// import vuxLocales from './locales/all.yml'
// import componentsLocales from './locales/components.yml'
// 引入vux localePlugin插件 保存本地语言环境
// import { LocalePlugin } from 'vux'

fastClick.attach(document.body)
Vue.use(http)
Vue.use(VueI18n)

Vue.config.productionTip = false

// const finalLocales = {
//   en: objectAssign(vuxLocales['en'], componentsLocales['en']),
//   'zh-CN': objectAssign(vuxLocales['zh-CN'], componentsLocales['zh-CN']),
//   tw: objectAssign(vuxLocales['tw'], componentsLocales['tw'])
// }

// for (let i in finalLocales) {
//   Vue.i18n.add(i, finalLocales[i])
// }
// Vue.use(LocalePlugin)
// const nowLocale = Vue.locale.get()
// if (/zh/.test(nowLocale)) {
//   Vue.i18n.set('zh-CN')
// } else if (/en/.test(nowLocale)) {
//   Vue.i18n.set('en')
// } else {
//   Vue.i18n.set('tw')
// }

const i18n = new VueI18n({
  locale: 'zh', // 语言标识
  messages: {
    'zh': require('./common/lang/zh'), // 中文语言包
    'en': require('./common/lang/en') // 英文语言包
  }
})
/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  store,
  i18n,
  components: { App },
  template: '<App/>'
})
